package com.example.cyw.news;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.EditText;

import cn.bmob.v3.BmobUser;

public class WebActivity extends AppCompatActivity {
    private WebView webView;
    private Button  btn_comment;
    private EditText ed_comment;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_web);
       initView();
       getData();
        //评论按钮点击事件
        btn_comment.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //判断用户有没有登陆
               if (BmobUser.getCurrentUser()==null){
                   Intent intent=new Intent(WebActivity.this,LogActivity.class);
                   startActivity(intent);
               }
            }
        });

//        back.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                finish();
//            }
//        });
    }

    private void getData() {
        String url=getIntent().getStringExtra("url");

        webView.loadUrl(url);
    }

    private void initView() {
        webView= (WebView) findViewById(R.id.webView);
        ed_comment= (EditText) findViewById(R.id.ed_comment);
        btn_comment= (Button) findViewById(R.id.btn_comment);

    }
}
